#pragma once
#include "WindowManager.h"
#include "NPCMessage.h"
#include "Monster.h"
#include "Ground.h"
#include "Ball.h"
#include <Box2D/Box2D.h>
#include <string>

#include "Thor\Animation.hpp"


class NPC
{
private:
	b2World* world;
	WindowManager* window;
	b2Body* body;
	
	bool messageMode;
	int messageCount;
	bool complete;

	std::string title;
	std::string name;
	std::string blurb;
	std::vector<NPCMessage> messages;
	int numMessages;
	std::string resizeMessage(std::string);
	int game;

	std::string replaceSubstring(std::string, std::string&, std::string&);
	bool teleport;

	void addFrames(thor::FrameAnimation& animation, int x, int yFirst, int yLast, float duration = 1.f);

	thor::Animator<sf::Sprite, std::string> animator;

	sf::Clock clock;
	sf::Sprite sprite;
	sf::Image image;
	sf::Texture texture;

	bool goingRight;
	bool jumping;

	sf::Clock autoTransClock;
	bool autoTrans;

	Monster* monster;

	int messageTrans;
	bool once;

	std::vector<std::shared_ptr<Ball>> balls;

public:
	NPC(void);
	NPC(b2World* wo, WindowManager* win, float x, float y, std::string t, std::string n, std::string b, std::string g, std::vector<NPCMessage> msgs, bool tele);
	~NPC(void);

	void drawNPC();
	b2Vec2 getPosition(void);
	float getRadius(void);
	void startMessages(void);
	void nextMessage(void);
	bool isComplete(void);


	void reset(void);
	void finishNPC(void);

	void previousMessage(void);

	std::string getTitle(void);
	std::string getName(void);
	std::string getBlurb(void);
	std::vector<NPCMessage>* getMessages(void);

	float getHeight(void);

	void addMonster(Monster*);


	NPCMessage* getCurrentMessage();
	bool isFight(void);

	int getGame(void);

	void drawMessage(std::string);

	
};

